package gov.ccswj.modules.bdbusiness.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import gov.ccswj.modules.bdbusiness.entity.BBProjectEntity;
import gov.ccswj.modules.bdbusiness.service.BBProjectService;
import gov.ccswj.common.utils.PageUtils;
import gov.ccswj.common.utils.Query;
import gov.ccswj.common.utils.R;




/**
 * 
 * 
 * @author KY.Cheng
 * @email ********@gmail.com
 * @date 2017-11-20 09:49:05
 */
@RestController
@RequestMapping("/bdbusiness/bbproject")
public class BBProjectController {
	@Autowired
	private BBProjectService bBProjectService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("bdbusiness:bbproject:list")
	public R list(@RequestParam Map<String, Object> params){
		if (params.get("money")!=null) {
			String money = params.get("money").toString();
			if (money.equals("1")) {
				params.put("money1", "0");
				params.put("money2", "100");
			} else if (money.equals("2")) {
				params.put("money1", "100");
				params.put("money2", "1000");
			} else if (money.equals("3")) {
				params.put("money1", "1000");
			}
			params.remove("money");
		}
		
		//查询列表数据
        Query query = new Query(params);

		List<BBProjectEntity> bBProjectList = bBProjectService.queryList(query);
		int total = bBProjectService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(bBProjectList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("bdbusiness:bbproject:info")
	public R info(@PathVariable("id") Integer id){
		BBProjectEntity bBProject = bBProjectService.queryObject(id);
		
		return R.ok().put("bBProject", bBProject);
	}
	
}
